package com.wedo.mall.activity.user;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.LinearLayout;

import com.e.library.activity.EActivity;
import com.e.library.http.EObserver;
import com.e.library.http.EResponse;
import com.wedo.mall.R;
import com.wedo.mall.entity.Article;
import com.wedo.mall.widget.EWebView;

import butterknife.BindView;
import io.reactivex.Observable;

public class AboutUsActivity extends EActivity {

    @BindView(R.id.ll_web) LinearLayout ll_web;
    private EWebView eWebView;

    @Override
    protected int layout() {
        return R.layout.activity_about_us;
    }

    @Override
    protected void onActivityCreated(Bundle state) {
        eWebView = new EWebView(ll_web);
        article();
    }

    @Override
    protected void onPause() {
        super.onPause();
        isCorE();
    }

    private void article(){
        loading();
        Observable<EResponse> observable = api().article(Article.SIGN_ABOUT);
        observer(observable, new EObserver() {
            @Override
            public void successful(EResponse response) {
                dismiss();
                Article article = response.object("list",Article.class);
                if(article == null || TextUtils.isEmpty(article.content)) {
                    return;
                }
                eWebView.data(article.content);
            }

            @Override
            public void failure(String msg) {
                dismiss(msg);
            }
        });
    }

    @Override
    protected void onDestroy() {
        eWebView.onDestroy();
        super.onDestroy();
    }
}
